import cookie from "js-cookie";

const tokenKey = "admin_token";
const usernameKey = "username";

/**
 * 从cookie中获取token
 * @returns 
 */
export function getToken() {
    return cookie.get(tokenKey);
}

/**
 * 将token放到cookie
 * @param {*} token 
 * @returns
 */
export function setToken(token) {
    return cookie.set(tokenKey, token);
}

/**
 * 从cookie中移除token
 * @returns 
 */
export function removeToken() {
    return cookie.remove(tokenKey);
}

/**
 * 从cookie中获取用户名
 * @returns 
 */
export function getUsername() {
    return cookie.get(usernameKey);
}

/**
 * 将用户名放到cookie
 * @param {*} username 
 * @returns
 */
export function setUsername(username) {
    return cookie.set(usernameKey, username);
}

/**
 * 从cookie中移除用户名
 * @returns 
 */
export function removeUsername() {
    return cookie.remove(usernameKey);
}